// #ifndef APP-NVUE
import {v4 as uuv4} from 'uuid'
// #endif
// #ifdef APP-NVUE
import uuv4 from "@/uview-ui/libs/function/guid.js"
// #endif
export const resCmdTypes = { 
	records:20, 
	offline:21, 
	chat:11, 
	penetrate:22, 
	read:25,
	login:6 ,
	chatEcho:12,
	logout:14, 
}
export const reqCmdTypes = {
	records:19, 
	offline:19, 
	chat:11, 
	penetrate:22 ,
	read:24,
	heart:13, 
	logout:14
}
export default{
	heartbeat(){
		return {cmd:reqCmdTypes.heart,hbbyte:-127}
	},
	chatMsg({from,to,content,groupId,msgType,extras={},chatType=2}){
		return {
			id:uuv4(),
			from,
			to,
			cmd:reqCmdTypes.chat,
			createTime:Date.now(),
			chatType,
			groupId,
			msgType,
			content,
			extras
		}
	},
	
	
	penetrate({from,chatType=2,to,groupId,content,msgType,extras={}}){
		return {
			id:uuv4(),
			from,
			to,
			groupId,
			cmd:reqCmdTypes.penetrate,
			createTime:Date.now(),
			chatType,
			msgType,
			content,
			extras
		}
	},
	
	read({userId,toObjId,toObjType,msgId,msgTime}){
		return {
			id:uuv4(),
			cmd:reqCmdTypes.read,
			userId,
			toObjId,
			toObjType,
			msgId,
			msgTime
		}
	},
	
	records({userId,to,offset}){ 
		return{
			cmd:reqCmdTypes.records,
			userId,
			offset,
			fromUserId:to,
			count:10,
			type:1
		}
	},
	history({userId,offset,count=10,...rest}){
		return{
			cmd:reqCmdTypes.records,
			userId,
			offset,
			count,
			type:1,
			...rest
		}
	},
	offline({userId}){ 
		return{
			cmd:reqCmdTypes.offline,
			userId,
			type:0
		}
	},
	logout(userId){
		return {cmd:reqCmdTypes.logout,userId}
	}
}